package com.example.mapp;

import com.example.entity.paperlessMaintance.PaperlessMaintanceApply;
import com.example.mapp.buildSql.PaperlessMaintMappSql;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PaperlessMaintMapp {

    @SelectProvider(type = PaperlessMaintMappSql.class,method = "queryPaperlessMaint")
    List<PaperlessMaintanceApply> query(PaperlessMaintanceApply paperlessMaintanceApply) throws Exception;

    @UpdateProvider(type = PaperlessMaintMappSql.class,method = "updatePaperlessMaint")
    int update(PaperlessMaintanceApply paperlessMaintanceApply) throws Exception;

    @Insert("INSERT INTO paperless_maintance_apply (apply_status, business_license_img, business_license_num, " +
            "contacts, contacts_address, contacts_card, contacts_emile, contacts_mobile, contacts_phone, contacts_work," +
            " corporation, credit_code, party_addr, party_area, party_city, party_name, party_province, party_type, " +
            "postal_code, remarks, apply_date, approval_date, telephone, zzdj, zzzs, jg_party_id,jg_party_name," +
            "parent_jg_party_id,user_code,password,maint_start) " +
            "VALUES (#{applyStatus}, #{businessLicenseImg}, #{businessLicenseNum}, #{contacts}, #{contactsAddress}, #{contactsCard}," +
            " #{contactsEmile}, #{contactsMobile}, #{contactsPhone}, #{contactsWork}, #{corporation}, #{creditCode}, #{partyAddr}, " +
            "#{partyArea}, #{partyCity}, #{partyName}, #{partyProvince}, #{partyType}, #{postalCode}, #{remarks}, " +
            "#{applyDate}, #{approvalDate}, #{telephone}, #{zzdj}, #{zzzs}, #{jgPartyId},#{jgPartyName},#{parentJgPartyId}," +
            "#{userCode},#{password},#{maintStart});\n")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id",before = false,resultType = Long.class)
    int insert(PaperlessMaintanceApply paperlessMaintanceApply) throws Exception;

    @Select("select * from paperless_maintance_apply where id = #{id}")
    PaperlessMaintanceApply queryById(String id);
}
